/*
 * Copyright(C) 2013-2017 AZ ALL Rights Reserved.
 *
 * FileName: TestLOg
 * 
 * Description: xxxxx
 *
 * History:
 * 版本号                作者      日期      操作
 * 1.0       ZhouFan             2017/10/12 0012   
 *  
 */
package com.az.shiro.ice.log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * @author ZhouFan
 * @version 1.0
 * @date 2017/10/12 0012
 * @see
 */
public class UnixProgramming {

    public static void main(String[] args) {
        Runtime runtime = Runtime.getRuntime();
        Scanner cin = new Scanner(System.in);
        StringBuffer cmdout = new StringBuffer();
        String cmd = cin.nextLine();
        try {
            Process process = runtime.exec(cmd);
            InputStream fis = process.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(fis));
            String line = null;

            while ((line = br.readLine()) != null) {
                cmdout.append(line).append(System.getProperty("line.separator"));
            }
            System.out.println("执行系统命令后的结果为：\n" + cmdout.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

 